package org.lgiavedoni.android.franq.event;

import lombok.AllArgsConstructor;
import lombok.Data;

import org.lgiavedoni.android.franq.core.calendar.CalendarEvent;
import org.lgiavedoni.android.franq.core.calendar.CalendarEventImp;
import org.lgiavedoni.android.franq.core.calendar.RegisterCalendarEvent;
import org.lgiavedoni.android.franq.core.contact.Contact;
import org.lgiavedoni.android.franq.core.envent.Event;
import org.lgiavedoni.android.franq.service.phone.ContactService;

@Data
@AllArgsConstructor
public class CallFromEvent extends Event implements RegisterCalendarEvent {

	private final String number;

	@Override
	public CalendarEvent toCalendarEvent() {
		Contact contact = ContactService.inst.getContactByNumber(number);
		String contactString = contact != null ? contact.getName() : number;
		return new CalendarEventImp("Call from: " + contactString, "Call from: " + contactString, getCreationDate());
	}

}
